<?php

declare(strict_types=1);

namespace App\Model\PssModel;

use App\Model\BaseModel\BasePssModel;
class ShopHomeShow extends BasePssModel
{
    public $table = 'shop_home_show';
    public const BANNER=1;
    public const BRAND=2;
    public const TOPIC=3;
    public const SECKILL=4;
    public const JUMP_URL=5;
    /**
     * 获取所有基础配置
     * @param array $types
     */
    public function getHomeShowConfigDataByShowType( array $types = [] ) 
    {
        return $this->whereIn('show_type',$types)
        ->select(['show_type','value','sort'])
        ->get()
        ->toArray();
    }

    public function getHomeShowConfigOneByShowType( string $type = '' )
    {
        $data = $this->where('show_type',$type)
            ->select(['show_type','value','sort'])
            ->first();
        if (!empty($data)){
            $data = $data->toArray();
            return json_decode($data['value'],true) ?? [];
        }else{
            return [];
        }
    }
}